package com.laogao.exception;

import com.laogao.common.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.net.BindException;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public R<?> exception(Exception e) {
        return R.error(500, "系统异常：" + e.getMessage());
    }

    @ExceptionHandler(BindException.class)
    public R<?> bind(Exception e) {
        return R.error(500, "系统异常：" + e.getMessage());
    }

}